package com.example.videotimedemo;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.bumptech.glide.Glide;
import com.example.videotimedemo.app.App;

import cn.jzvd.JZMediaSystem;
import cn.jzvd.Jzvd;
import cn.jzvd.JzvdStd;

import static com.example.videotimedemo.MainActivity.videoUrl;

public class VideoDetailActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        JzvdStd jzvdStd = findViewById(R.id.videoplayer);
        if (jzvdStd != null) {
            jzvdStd.setMediaInterface(JZMediaSystem.class);
            String proxyUrl = App.getProxy(this).getProxyUrl(videoUrl);
            jzvdStd.setUp(proxyUrl, "饺子来看看", JzvdStd.SCREEN_NORMAL, JZMediaSystem.class);
            jzvdStd.onPrepared();
            Glide.with(this).load("http://8.136.101.204/v/饺子来看看.jpg").into(jzvdStd.thumbImageView);

        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        Jzvd.releaseAllVideos();
    }

    @Override
    protected void onResume() {
        super.onResume();
        Jzvd.goOnPlayOnResume();
    }

    @Override
    public void onBackPressed() {
        if (Jzvd.backPress()) {
            return;
        }
        super.onBackPressed();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Jzvd.releaseAllVideos();
    }
}
